import React from "react";

import { connect } from "react-redux";

import { getHomeList } from "./store/thnukDemo/actionCreators";

const Index = (props) => {
  return (
    <div>
      <ul>
        {props.recomms.map((v) => (
          <li key={v.acm}>{v.title}</li>
        ))}
      </ul>
      <button
        onClick={(e) => {
          props.getList();
        }}
      >
        查看数据
      </button>
      {props.banners.map((v) => (
        <img key={v.acm} src={v.image} alt="" />
      ))}
    </div>
  );
};

const mapStateToProps = (state) => ({
  banners: state.banners,
  recomms: state.recomm,
});

const mapDispatchToPros = (dispatch) => ({
  getList() {
    dispatch(getHomeList);
  },
});

export default connect(mapStateToProps, mapDispatchToPros)(Index);
